<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>后台主页模块 - XzcBlogTemplate后台管理</title>
    <link rel="stylesheet" href="static/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="static/admin/css/common.css">
    <link rel="stylesheet" type="text/css" href="static/admin/css/blogadd.css">
</head>
<body>
<div class="layui-container main">
    <div class="layui-row layui-col-space20">
        <div class="layui-col-md12">
            <p>
		        	<span class="layui-breadcrumb" style="visibility: visible;">
			          	<a href="./bloglist.html">博客管理系统</a><span lay-separator="">/</span>
			          	<a href="./bloglist.html">后台首页</a><span lay-separator="">/</span>
			          	<a><cite>文章管理</cite></a>
		        	</span>
            </p>
        </div>
        <div class="layui-col-md12">
            <table class="layui-table">
                <colgroup>
                    <col width="200">
                    <col width="400">
                    <col>
                </colgroup>
                <thead>
                <tr>
                    <th>标题</th>
                    <th>内容简介</th>
                    <th>分类/标签</th>

                    <th>是否置顶</th>
                    <th>查看数</th>
                    <th>发布时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td id="a1"></td>
                    <td id="a2">

                    </td>
                    <td>闲言碎语</td>
                    <td id="a3"></td>
                    <td id="a4"><input type="checkbox" name="zzz" lay-skin="switch" lay-text="开启|关闭"></td>
                    <td id="a5"></td>
                    <td id="a6"></td>
                    <td>
                        <a href="blogupdate.html" class="layui-btn layui-btn-normal">编辑</a>
                        <a id="del_btn" href="javascript:;" class="layui-btn layui-btn-danger">删除</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<input type="hidden" name="uid">
</body>
<script src="static/js/jquery-1.12.4.min.js"></script>
<script src="static/layui/layui.all.js"></script>
<script>
    $(function () {
        $("#del_btn").click(function () {
            layer.confirm("数据已经发生改变是否确认修改？", {
                btn: ["确定", "取消"] //按钮
            }, function (index) {
                alert('点击了确认的回调函数');
                layer.close(index);
            }, function () {
                alert('点击了取消的回调函数');
                layer.close();
            });
        });
    });

    $(document).ready(function () {
        var uid = sessionStorage.getItem('uid');
        $.get("blog/findByUid", {
            "uid": uid
        }, function (rs) {
            $("tbody").empty();
            var wos = rs.result;
            for (var i = 0; i < wos.length; i++) {
                $("<tr>\n" +
                    "        <td id='a1'>" + wos[i].title + "</td>\n" +
                    "        <td id='a2'>" + wos[i].detail + "</td>\n" +
                    "        <td id='a3'>" + wos[i].typeName + "</td>\n" +
                    "        <td id='a4'>" + wos[i].status + "</td>\n" +
                    "        <td id='a5'>" + wos[i].clicknumber + "</td>\n" +
                    "        <td id='a6'>" + wos[i].posttime + "</td>\n" +
                    "<td>\n" +
                    "                        <a name='" + wos[i].blogid + "' id='update' href=\"blogupdate.html\" class=\"layui-btn layui-btn-normal\">编辑</a>\n" +
                    "                        <a name='" + wos[i].blogid + "' id=\"del_btn\" href=\"javascript:;\" class=\"layui-btn layui-btn-danger\">删除</a>\n" +
                    "                    </td>" +
                    "    </tr>").appendTo("tbody");
            }
        })
    });
    $(document).on("click", "#del_btn", function () {
        var blogid = $(this).attr("name");
        var uid = sessionStorage.getItem('uid');
        $.get("blog/deleteByBlogId", {
            "blogid": blogid,
            "uid": uid
        }, function (rs) {
            alert("删除成功")
            $("tbody").empty();
            var wos = rs.result;
            for (var i = 0; i < wos.length; i++) {
                $("<tr>\n" +
                    "        <td id='a1'>" + wos[i].title + "</td>\n" +
                    "        <td id='a2'>" + wos[i].detail + "</td>\n" +
                    "        <td id='a3'>" + wos[i].typeName + "</td>\n" +
                    "        <td id='a4'>" + wos[i].status + "</td>\n" +
                    "        <td id='a5'>" + wos[i].clicknumber + "</td>\n" +
                    "        <td id='a6'>" + wos[i].posttime + "</td>\n" +
                    "<td>\n" +
                    "                        <a name='" + wos[i].blogid + "' id='update' href=\"blogupdate.html\" class=\"layui-btn layui-btn-normal\">编辑</a>\n" +
                    "                        <a name='" + wos[i].blogid + "' id=\"del_btn\" href=\"javascript:;\" class=\"layui-btn layui-btn-danger\">删除</a>\n" +
                    "                    </td>" +
                    "    </tr>").appendTo("tbody");
            }
        });
    });
    $(document).on("click","#update",function () {
        var blogid = $(this).attr("name");

        sessionStorage.setItem('blogid',blogid);

    })
</script>
</html>